#include "StdAfx.h"
#include "GameBase.h"
#include "SubStructure.h"
#include "Item.h"

Item::Item()
{
}

Item::~Item()
{
}

void Item::Init()
{
	MakeTime = 0;
	velocity.x = 0.0f;
	velocity.y = -3.0f;
	forced = false;
}

void Item::Draw()
{
	D3DXMATRIX matrix;
	D3DXMatrixIdentity(&matrix);

	D3DXMatrixTransformation2D(&matrix, 0, 0, 0, 0 ,0, &this_pos);
	
	GameBase::pSprite->SetTransform(&matrix);
	
	GameBase::pSprite->Draw(Texture,
					&Source,
					NULL,
					NULL,
					Invisible);

	D3DXMatrixIdentity(&matrix);
	GameBase::pSprite->SetTransform(&matrix);
}

void Item::Move(D3DXVECTOR2 nPos)
{
	if(!forced || MakeTime < 40)
	{
		velocity.x = 0.0f;
		this_pos += velocity;
		if(velocity.y < 2.9f)
			velocity.y += 0.06f;
	}
	else
	{
		D3DXVECTOR2 tempvel = nPos - this_pos;
		float sqrted = sqrt(tempvel.x * tempvel.x + tempvel.y * tempvel.y);
		this_pos.x = this_pos.x + 5.0f * (tempvel.x / sqrted);
		this_pos.y = this_pos.y + 5.0f * (tempvel.y / sqrted);
	}
	MakeTime++;
}

void Item::ForceGrep()
{
	forced = (!forced);
}

bool Item::GetForced(){ return forced; }

void Item::Update()
{
}

DWORD Item::GetMakeTime()
{
	return MakeTime;
}

D3DXVECTOR2 Item::GetNowPos()
{
	return this_pos;
}

DWORD Item::deleteCheck()
{
	if(this_pos.y > 510.0)
	{
		return OVERRANGEDELETE;
	}
	return 0;	
}

void Item::Set_kind(DWORD nk)
{
	kind = nk;
}

DWORD Item::Get_kind()
{
	return kind;
}